package springIOC.IOC_XML.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import springIOC.IOC_XML.beans.Account;
import springIOC.IOC_XML.beans.BeanInfo;
import springIOC.IOC_XML.beans.User;
import springIOC.IOC_XML.dao.UserDao;
import springIOC.IOC_XML.service.UserService;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
@Scope("prototype")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public User findUserByID(int uid) {
        return userDao.findUserByID(uid);
//        return userDao.findUserByName("jerry");
    }
    @Override
    public List<User> findUserByName(String name) {
        return userDao.findUserByName(name);
    }



    //    -----------------------------------------------------------------------
//    @Autowired
//    @Qualifier("account")
    @Resource(name = "account")
    private Account account;

    @Override
    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

//---------------------------------------------------------------------------

    @Autowired
    @Qualifier("beanInfo")
    private BeanInfo beanInfo;

    public BeanInfo getBeanInfo() {
        return beanInfo;
    }


    public void setBeanInfo(BeanInfo beanInfo) {
        this.beanInfo = beanInfo;
    }

}
